package com.bw.apply.adpter

import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.widget.TextView
import com.bw.apply.R
import com.bw.apply.entity.ApplyEntity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import org.w3c.dom.Text

class ApplyAdapter : BaseQuickAdapter<ApplyEntity,BaseViewHolder>(R.layout.item_apply) {
    @SuppressLint("ResourceType")
    override fun convert(holder: BaseViewHolder, item: ApplyEntity) {
        val view1 = holder.getView<TextView>(R.id.title)
        view1.text = item.title
        val drawable = GradientDrawable()
        drawable.cornerRadius = 18f
        view1.background = drawable
        view1.setTextColor(Color.parseColor("#55A4EA"))
        drawable.setColor(Color.parseColor("#E8F3FC"))
        val view2 = holder.getView<TextView>(R.id.status)
        view2.text = item.status
        val drawable1 = GradientDrawable()
        drawable1.cornerRadius = 10f
        if (item.status.contains("待审批")){
            drawable1.setColor(Color.parseColor("#F9EABE"))
            view2.setTextColor(Color.parseColor("#F0CC63"))
        }else if (item.status.contains("已通过")){
            drawable1.setColor(Color.parseColor("#FDFEFE"))
            view2.setTextColor(Color.parseColor("#42CD7B"))
        }else if (item.status.contains("已拒绝")){
            drawable1.setColor(Color.parseColor("#E8D3D3"))
            view2.setTextColor(Color.parseColor("#D95756"))
        }

        holder.getView<TextView>(R.id.desc).text = item.desc
        holder.getView<TextView>(R.id.time).text = item.time

    }
}